﻿@model ImageEditor

@section styles{
    @Styles.Render("~/Content/bootstrap-select.css")
}

@{
    string title = ViewBag.Title;
    string returnListUrl = ViewBag.ReturnListUrl;
    Product product = ViewBag.Product;

    SelectList colorDDL = ViewBag.ColorDDL;

    ViewBag.Title = "Chỉnh sửa " + title;
}

<section class="content-header">
    <h1>
        @title.ToUpper() <small>chỉnh sửa</small>
    </h1>
    <ol class="breadcrumb">
        <li>
            <a href="@Url.Action("Index", "Admin")">
                <i class="fa fa-home"></i> Trang chủ
            </a>
        </li>
        <li>
            <a href="@Url.Action("Index", "Product")">
                Danh sách sản phẩm
            </a>
        </li>
        <li>
            <a href="@Url.Action("Index", "Product", new { search = product.Code })">
                @product.Name - @product.Code
            </a>
        </li>
        <li>
            <a href="@Url.Action("Index", new { productId = product.Id })">
                Danh sách @title
            </a>
        </li>
        <li class="active">Chỉnh sửa</li>
    </ol>
</section>

<section class="content">
    <div class="row">
        <div class="col-md-4">
            @using (Html.BeginForm("Edit", "Image", FormMethod.Post, new { enctype = "multipart/form-data" }))
            {
                @Html.AntiForgeryToken()
                @Html.HiddenFor(m => m.Id)
                @Html.Hidden("ReturnListUrl", returnListUrl)

                <div class="box box-primary">
                    <div class="box-body">
                        @if (ViewBag.ColorDDL != null)
                        {
                            <div class="form-group">
                                <label class="control-label">Màu</label>
                                @Html.DropDownListFor(m => m.PropertyId, colorDDL, "Chọn màu",
                                new
                                {
                                    @class = "selectpicker no-margin",
                                    data_width = "100%",
                                    data_size = "auto",
                                    data_live_search = "true"
                                })
                                @Html.ValidationMessageFor(m => m.PropertyId)
                            </div>
                        }
                        <div class="form-group">
                            <label class="control-label">Hình thay thế</label>
                            <input name="Image" type="file" class="form-control" accept="image/*">
                            @Html.ValidationMessageFor(m => m.Image)
                        </div>
                        <div class="form-group">
                            @Html.CheckBoxFor(m => m.IsMainImage) ảnh đại diện
                        </div>
                    </div>
                    <div class="box-footer text-right">
                        <a href="@Request.UrlReferrer" class="btn btn-default pull-left">
                            <i class="fa fa-chevron-left"></i> Quay lại
                        </a>
                        <button type="reset" class="btn btn-warning">
                            <i class="fa fa-repeat"></i> Mặc định
                        </button>
                        <button type="submit" class="btn btn-success">
                            <i class="fa fa-check"></i> Xác nhận
                        </button>
                    </div>
                </div>
            }
        </div>
    </div>
</section>

@section scripts{
    @Scripts.Render("~/Scripts/bootstrap-select.js")
    <script>
        $('.selectpicker').selectpicker();

        ActiveMenu('product');
    </script>
}